/*
 * @lc app=leetcode.cn id=383 lang=typescript
 *
 * [383] 赎金信
 */

// @lc code=start
function canConstruct(ransomNote: string, magazine: string): boolean {
    const arr = new Array(26).fill(0);
    const base = 'a'.charCodeAt(0);
    for (let i = 0; i < magazine.length; i++) {
        arr[magazine[i].charCodeAt(0) - base]++;
    }

    for (let j = 0; j < ransomNote.length; j++) {
        const index = ransomNote[j].charCodeAt(0) - base;
        console.log(index)
        if (!arr[index]) {
            return false
        }
        arr[index]--;
    }
    return true;
};

// canConstruct('aa', 'aab')
// @lc code=end

